package com.lijianlove.keeplearning.dr.support.log;

import com.lijianlove.keeplearning.dr.support.log.event.ClearTimedKeyEvent;
import com.lijianlove.keeplearning.dr.support.log.event.RunLogEvent;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**
 * @author lijian
 * @date 2019/5/1 上午12:52
 */
@Component
public class EventPublisher implements ApplicationContextAware {

    private static ApplicationEventPublisher publisher;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        publisher = applicationContext;
    }

    public static void publish(ClearTimedKeyEvent event) {
        publisher.publishEvent(event);
    }

    public static void publish(RunLogEvent event) {
        publisher.publishEvent(event);
    }

}
